import numpy as np

"""
3 --- 2 ---> 6
target value is 10
predicted value is 6
"""

x = 3
weight = 2
target = 10

for i in range(200):
    # 损失值
    loss = (weight * x - target) ** 2
    # 学习率
    learning_rate = 0.01
    # 损失函数-权重斜率（梯度）
    gradient = loss / weight
    weight = weight - learning_rate * gradient
    pred = x * weight
    print(f'weight: {weight}，pred：{pred}')
